#ifndef LAURIN_80211_FRAME_H_
#define LAURIN_80211_FRAME_H_

#include "laurin-radio-info.h"
#include "linux_ieee80211_radiotap.h"
#include <sys/types.h>


class Laurin80211Frame
{

	public:

		enum Laurin80211FrameType
		{
			BEACON = 0,
			DATA,
			ACK,
			NOT_VALID
		};

		Laurin80211Frame();

		/**
		 * Use only on already parsed (both parse80211Frame() and parseRadiotapHeader()) frame because memory is not managed.
		 */
		Laurin80211Frame(const Laurin80211Frame& frame);
		virtual ~Laurin80211Frame();


		bool setFrame(const u_char* frame, int length);
		bool parse80211Frame();
		bool parseRadiotapHeader();


		/**
		 * Is considered only the frame without the radiotap header
		 */
		int FrameLength;
		Laurin80211FrameType FrameType;


		u_int8_t* getSourceAddress() const;
		u_int8_t* getDestinationAddress() const;
		u_int8_t* getBSSIDAddress() const;


		LaurinBeaconDetails getBeaconDetails() const;
		LaurinPacketRadioInfo getRadioInformations() const;


		bool operator <(const Laurin80211Frame& frame);

	private:

		u_int8_t* _source;
		u_int8_t* _destination;
		u_int8_t* _bssid;

		const u_char* _frame;
		struct ieee80211_radiotap_header* _radiotap;
		struct LaurinBeaconDetails _beacon_details;
		struct LaurinPacketRadioInfo _radio;


		bool parse80211Header();
};


#endif
